home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / X11 / extensions / syncstr.h < prev    next >
C/C++ Source or Header  |  2006-04-12  |  12KB  |  495 lines

  1. /* $Xorg: syncstr.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
  2. /*
  3.  
  4. Copyright 1991, 1993, 1994, 1998  The Open Group
  5.  
  6. Permission to use, copy, modify, distribute, and sell this software and its
  7. documentation for any purpose is hereby granted without fee, provided that
  8. the above copyright notice appear in all copies and that both that
  9. copyright notice and this permission notice appear in supporting
  10. documentation.
  11.  
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14.  
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  18. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  19. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21.  
  22. Except as contained in this notice, the name of The Open Group shall not be
  23. used in advertising or otherwise to promote the sale, use or other dealings
  24. in this Software without prior written authorization from The Open Group.
  25.  
  26. */
  27.  
  28. /***********************************************************
  29. Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
  30. and Olivetti Research Limited, Cambridge, England.
  31.  
  32.                         All Rights Reserved
  33.  
  34. Permission to use, copy, modify, and distribute this software and its 
  35. documentation for any purpose and without fee is hereby granted, 
  36. provided that the above copyright notice appear in all copies and that
  37. both that copyright notice and this permission notice appear in 
  38. supporting documentation, and that the names of Digital or Olivetti
  39. not be used in advertising or publicity pertaining to distribution of the
  40. software without specific, written prior permission.  
  41.  
  42. DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  43. SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  44. FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  45. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  46. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  47. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  48. PERFORMANCE OF THIS SOFTWARE.
  49.  
  50. ******************************************************************/
  51. /* $XFree86: xc/include/extensions/syncstr.h,v 1.3 2003/07/16 01:38:24 dawes Exp $ */
  52.  
  53. #ifndef _SYNCSTR_H_
  54. #define _SYNCSTR_H_
  55.  
  56. #include "sync.h"
  57.  
  58. #ifndef _SYNC_OS
  59.  
  60. /* cover up types from sync.h to make sure they're the right size for
  61.  * protocol packaging.  These will be undef'ed after all the protocol
  62.  * structures are defined.
  63.  */
  64. #define XSyncCounter CARD32
  65. #define XSyncAlarm   CARD32
  66.  
  67. /*
  68.  * Initialize
  69.  */
  70. typedef struct _xSyncInitialize {
  71.     CARD8    reqType;
  72.     CARD8    syncReqType;
  73.     CARD16    length B16;
  74.     CARD8    majorVersion;
  75.     CARD8    minorVersion;
  76.     CARD16    pad B16;
  77. } xSyncInitializeReq;
  78. #define sz_xSyncInitializeReq        8
  79.  
  80. typedef struct {
  81.     BYTE    type;
  82.     CARD8    unused;
  83.     CARD16    sequenceNumber B16;
  84.     CARD32    length B32;
  85.     CARD8    majorVersion;
  86.     CARD8    minorVersion;
  87.     CARD16    pad B16;
  88.     CARD32    pad0 B32;
  89.     CARD32    pad1 B32;
  90.     CARD32    pad2 B32;
  91.     CARD32    pad3 B32;
  92.     CARD32    pad4 B32;
  93. } xSyncInitializeReply;
  94. #define sz_xSyncInitializeReply    32
  95.  
  96. /*
  97.  * ListSystemCounters
  98.  */
  99. typedef struct _xSyncListSystemCounters
  100. {
  101.     CARD8    reqType;
  102.     CARD8    syncReqType;
  103.     CARD16    length B16;
  104. } xSyncListSystemCountersReq;
  105. #define sz_xSyncListSystemCountersReq    4
  106.  
  107. typedef struct {
  108.     BYTE    type;
  109.     CARD8    unused;
  110.     CARD16    sequenceNumber B16;
  111.     CARD32    length B32;
  112.     INT32    nCounters B32;
  113.     CARD32    pad0 B32;
  114.     CARD32    pad1 B32;
  115.     CARD32    pad2 B32;
  116.     CARD32    pad3 B32;
  117.     CARD32    pad4 B32;
  118. } xSyncListSystemCountersReply;
  119. #define sz_xSyncListSystemCountersReply    32
  120.  
  121. typedef struct {
  122.     XSyncCounter counter B32;
  123.     INT32    resolution_hi B32;
  124.     CARD32    resolution_lo B32;
  125.     CARD16    name_length B16;
  126. } xSyncSystemCounter;
  127. #define sz_xSyncSystemCounter 14
  128.  
  129. /*
  130.  * Create Counter
  131.  */
  132. typedef struct _xSyncCreateCounterReq {
  133.     CARD8    reqType;
  134.     CARD8    syncReqType;
  135.     CARD16    length B16;
  136.     XSyncCounter cid B32;
  137.     INT32       initial_value_hi B32;
  138.     CARD32    initial_value_lo B32;
  139. } xSyncCreateCounterReq;
  140. #define sz_xSyncCreateCounterReq    16
  141.  
  142. /*
  143.  * Change Counter
  144.  */
  145. typedef struct _xSyncChangeCounterReq {
  146.     CARD8    reqType;
  147.     CARD8    syncReqType;
  148.     CARD16    length B16;
  149.     XSyncCounter cid B32;
  150.     INT32       value_hi B32;
  151.     CARD32    value_lo B32;
  152. } xSyncChangeCounterReq;
  153. #define sz_xSyncChangeCounterReq    16
  154.  
  155. /*
  156.  * Set Counter
  157.  */
  158. typedef struct _xSyncSetCounterReq {
  159.     CARD8    reqType;
  160.     CARD8    syncReqType;
  161.     CARD16    length B16;
  162.     XSyncCounter cid B32;
  163.     INT32       value_hi B32;
  164.     CARD32    value_lo B32;
  165. } xSyncSetCounterReq;
  166. #define sz_xSyncSetCounterReq    16
  167.  
  168. /*
  169.  * Destroy Counter
  170.  */
  171. typedef struct _xSyncDestroyCounterReq {
  172.     CARD8    reqType;
  173.     CARD8    syncReqType;
  174.     CARD16    length B16;
  175.     XSyncCounter counter B32;
  176. } xSyncDestroyCounterReq;
  177. #define sz_xSyncDestroyCounterReq    8
  178.  
  179. /*
  180.  * Query Counter
  181.  */
  182. typedef struct _xSyncQueryCounterReq {
  183.     CARD8    reqType;
  184.     CARD8    syncReqType;
  185.     CARD16    length B16;
  186.     XSyncCounter counter B32;
  187. } xSyncQueryCounterReq;
  188. #define sz_xSyncQueryCounterReq        8
  189.  
  190.  
  191. typedef struct {
  192.     BYTE    type;
  193.     CARD8    unused;
  194.     CARD16    sequenceNumber B16;
  195.     CARD32    length B32;
  196.     INT32    value_hi B32;
  197.     CARD32    value_lo B32;
  198.     CARD32    pad0 B32;
  199.     CARD32    pad1 B32;
  200.     CARD32    pad2 B32;
  201.     CARD32    pad3 B32;
  202. } xSyncQueryCounterReply;
  203. #define sz_xSyncQueryCounterReply    32
  204.  
  205. /*
  206.  * Await
  207.  */
  208. typedef struct _xSyncAwaitReq {
  209.     CARD8    reqType;
  210.     CARD8    syncReqType;
  211.     CARD16    length B16;
  212. } xSyncAwaitReq;
  213. #define sz_xSyncAwaitReq        4
  214.  
  215. typedef struct _xSyncWaitCondition {
  216.     XSyncCounter counter B32;
  217.     CARD32    value_type B32;
  218.     INT32       wait_value_hi B32;
  219.     CARD32      wait_value_lo B32;
  220.     CARD32    test_type B32;
  221.     INT32    event_threshold_hi B32;
  222.     CARD32    event_threshold_lo B32;
  223. } xSyncWaitCondition;
  224. #define sz_xSyncWaitCondition        28
  225.  
  226. /*
  227.  * Create Alarm
  228.  */
  229. typedef struct _xSyncCreateAlarmReq {
  230.     CARD8    reqType;
  231.     CARD8    syncReqType;
  232.     CARD16    length B16;
  233.     XSyncAlarm    id B32;
  234.     CARD32      valueMask B32;
  235. } xSyncCreateAlarmReq;
  236. #define sz_xSyncCreateAlarmReq        12
  237.  
  238. /*
  239.  * Destroy Alarm
  240.  */
  241. typedef struct _xSyncDestroyAlarmReq {
  242.     CARD8    reqType;
  243.     CARD8    syncReqType;
  244.     CARD16    length B16;
  245.     XSyncAlarm    alarm B32;
  246. } xSyncDestroyAlarmReq;
  247. #define sz_xSyncDestroyAlarmReq        8
  248.  
  249. /*
  250.  * Query Alarm
  251.  */
  252. typedef struct _xSyncQueryAlarmReq {
  253.     CARD8    reqType;
  254.     CARD8    syncReqType;
  255.     CARD16    length B16;
  256.     XSyncAlarm    alarm B32;
  257. } xSyncQueryAlarmReq;
  258. #define sz_xSyncQueryAlarmReq        8
  259.  
  260. typedef struct {
  261.     BYTE    type;
  262.     CARD8    unused;
  263.     CARD16    sequenceNumber B16;
  264.     CARD32    length B32;
  265.     XSyncCounter counter B32;
  266.     CARD32    value_type B32;
  267.     INT32    wait_value_hi B32;
  268.     CARD32    wait_value_lo B32;
  269.     CARD32    test_type      B32;
  270.     INT32    delta_hi B32;
  271.     CARD32    delta_lo B32;
  272.     BOOL        events;
  273.     BYTE        state;
  274.     BYTE    pad0;
  275.     BYTE    pad1;
  276. } xSyncQueryAlarmReply;
  277. #define sz_xSyncQueryAlarmReply        40
  278.  
  279. /*
  280.  * Change Alarm
  281.  */
  282. typedef struct _xSyncChangeAlarmReq {
  283.     CARD8    reqType;
  284.     CARD8    syncReqType;
  285.     CARD16    length B16;
  286.     XSyncAlarm    alarm B32;
  287.     CARD32    valueMask B32;
  288. } xSyncChangeAlarmReq;
  289. #define sz_xSyncChangeAlarmReq        12
  290.  
  291. /*
  292.  * SetPriority
  293.  */
  294. typedef struct _xSyncSetPriority{
  295.     CARD8       reqType;
  296.     CARD8       syncReqType;
  297.     CARD16      length B16;
  298.     CARD32      id B32;
  299.     INT32      priority B32;
  300. } xSyncSetPriorityReq;
  301. #define sz_xSyncSetPriorityReq            12
  302.  
  303. /*
  304.  * Get Priority
  305.  */
  306. typedef struct _xSyncGetPriority{
  307.     CARD8       reqType;
  308.     CARD8       syncReqType;
  309.     CARD16      length B16;
  310.     CARD32      id B32; /*XXX XID? */
  311. } xSyncGetPriorityReq;
  312. #define sz_xSyncGetPriorityReq             8
  313.  
  314. typedef struct {
  315.     BYTE    type;
  316.     CARD8    unused;
  317.     CARD16    sequenceNumber B16;
  318.     CARD32    length B32;
  319.     INT32      priority B32;
  320.     CARD32      pad0 B32;
  321.     CARD32      pad1 B32;
  322.     CARD32      pad2 B32;
  323.     CARD32      pad3 B32;
  324.     CARD32      pad4 B32;
  325. } xSyncGetPriorityReply;
  326. #define sz_xSyncGetPriorityReply    32
  327.  
  328. /*
  329.  * Events
  330.  */
  331.  
  332. typedef struct _xSyncCounterNotifyEvent {
  333.     BYTE    type;
  334.     BYTE    kind;
  335.     CARD16    sequenceNumber B16;
  336.     XSyncCounter counter B32;
  337.     INT32    wait_value_hi B32;
  338.     CARD32    wait_value_lo B32;
  339.     INT32    counter_value_hi B32;
  340.     CARD32    counter_value_lo B32;
  341.     CARD32    time B32;
  342.     CARD16    count B16;
  343.     BOOL    destroyed;
  344.     BYTE        pad0;
  345. } xSyncCounterNotifyEvent;
  346.  
  347. typedef struct _xSyncAlarmNotifyEvent {
  348.     BYTE    type;
  349.     BYTE    kind;
  350.     CARD16    sequenceNumber B16;
  351.     XSyncAlarm    alarm B32;
  352.     INT32    counter_value_hi B32;
  353.     CARD32    counter_value_lo B32;
  354.     INT32    alarm_value_hi B32;
  355.     CARD32    alarm_value_lo B32;
  356.     CARD32    time B32;
  357.     CARD8       state;
  358.     BYTE        pad0;
  359.     BYTE        pad1;
  360.     BYTE        pad2;
  361. } xSyncAlarmNotifyEvent;
  362.  
  363. #undef XSyncCounter
  364. #undef XSyncAlarm
  365.  
  366. #endif /* _SYNC_OS */
  367.  
  368. #ifdef _SYNC_SERVER
  369.  
  370. #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
  371.  
  372. typedef struct _SyncCounter {
  373.     ClientPtr        client;    /* Owning client. 0 for system counters */
  374.     XSyncCounter    id;        /* resource ID */
  375.     CARD64        value;        /* counter value */
  376.     struct _SyncTriggerList *pTriglist;    /* list of triggers */
  377.     Bool        beingDestroyed; /* in process of going away */
  378.     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
  379. } SyncCounter;
  380.  
  381. /*
  382.  * The System Counter interface
  383.  */
  384.  
  385. typedef enum {
  386.     XSyncCounterNeverChanges,
  387.     XSyncCounterNeverIncreases,
  388.     XSyncCounterNeverDecreases,
  389.     XSyncCounterUnrestricted
  390. } SyncCounterType;
  391.  
  392. typedef struct _SysCounterInfo {
  393.     char    *name;
  394.     CARD64    resolution;
  395.     CARD64    bracket_greater;
  396.     CARD64    bracket_less;
  397.     SyncCounterType counterType;  /* how can this counter change */
  398.     void        (*QueryValue)(
  399.                   pointer /*pCounter*/,
  400.                   CARD64 * /*freshvalue*/
  401. );
  402.     void    (*BracketValues)(
  403.                  pointer /*pCounter*/,
  404.                  CARD64 * /*lessthan*/,
  405.                  CARD64 * /*greaterthan*/
  406. );
  407. } SysCounterInfo;
  408.  
  409.  
  410.  
  411. typedef struct _SyncTrigger {
  412.     SyncCounter *pCounter;
  413.     CARD64    wait_value;    /* wait value */
  414.     unsigned int value_type;     /* Absolute or Relative */
  415.     unsigned int test_type;    /* transition or Comparision type */
  416.     CARD64    test_value;    /* trigger event threshold value */
  417.     Bool    (*CheckTrigger)(
  418.                 struct _SyncTrigger * /*pTrigger*/,
  419.                 CARD64 /*newval*/
  420.                 );
  421.     void    (*TriggerFired)(
  422.                 struct _SyncTrigger * /*pTrigger*/
  423.                 );
  424.     void    (*CounterDestroyed)(
  425.                 struct _SyncTrigger * /*pTrigger*/
  426.                     );
  427. } SyncTrigger;
  428.  
  429. typedef struct _SyncTriggerList {
  430.     SyncTrigger *pTrigger;
  431.     struct _SyncTriggerList *next;
  432. } SyncTriggerList;
  433.  
  434. typedef struct _SyncAlarmClientList {
  435.     ClientPtr    client;
  436.     XID        delete_id;
  437.     struct _SyncAlarmClientList *next;
  438. } SyncAlarmClientList;
  439.  
  440. typedef struct _SyncAlarm {
  441.     SyncTrigger trigger;
  442.     ClientPtr    client;
  443.     XSyncAlarm     alarm_id;
  444.     CARD64    delta;
  445.     int        events;
  446.     int        state;
  447.     SyncAlarmClientList *pEventClients;
  448. } SyncAlarm;
  449.  
  450. typedef struct {
  451.     ClientPtr    client;
  452.     CARD32     delete_id;
  453.     int        num_waitconditions;
  454. } SyncAwaitHeader;
  455.  
  456. typedef struct {
  457.     SyncTrigger trigger;
  458.     CARD64    event_threshold;
  459.     SyncAwaitHeader *pHeader;
  460. } SyncAwait;
  461.  
  462. typedef union {
  463.     SyncAwaitHeader header;
  464.     SyncAwait        await;
  465. } SyncAwaitUnion;
  466.  
  467.  
  468. extern pointer SyncCreateSystemCounter(
  469.     char *    /* name */,
  470.     CARD64      /* inital_value */,
  471.     CARD64      /* resolution */,
  472.     SyncCounterType /* change characterization */,
  473.     void        (* /*QueryValue*/ ) (
  474.         pointer /* pCounter */,
  475.         CARD64 * /* pValue_return */), /* XXX prototype */
  476.     void        (* /*BracketValues*/) (
  477.         pointer /* pCounter */, 
  478.         CARD64 * /* pbracket_less */,
  479.         CARD64 * /* pbracket_greater */)
  480. );
  481.  
  482. extern void SyncChangeCounter(
  483.     SyncCounter *    /* pCounter*/,
  484.     CARD64          /* new_value */
  485. );
  486.  
  487. extern void SyncDestroySystemCounter(
  488.     pointer pCounter
  489. );
  490. extern void InitServertime(void);
  491.  
  492. #endif /* _SYNC_SERVER */
  493.  
  494. #endif /* _SYNCSTR_H_ */
  495.